﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace MyBehaviorTree {
    public class Sequence : Composite
    {
        private int index = 0;
        public override void start()
        {
            index = 0;
        }
        public override State update()
        {
            while (index < children.Count)
            {
                var currentChild = children[index];
                var childState = currentChild.run();
                if (childState != State.SUSCCESS) return childState;
                index++;
            }
            return State.SUSCCESS;
        }
    }
}
